#!/usr/bin/env node

const http = require('https'),
      url  = require('url'),
      log  = console.log,
      city = process.argv[2] || '石家庄',
      addr = 'https://api.66mz8.com/api/weather.php?location=' + city;

log(addr);
log(global.encodeURI(addr));
process.exit();
let opt = url.parse(addr);
opt.headers = {
  'user-agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'
};

http.get(opt,(res)=>{
  log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);
  log(res.headers);
  res.pipe(process.stdout);
});
